﻿/*
{
"状态":1,
"名称":"修改-角色资料",
"作者":"陈泽椿",
"创建时间":"2018-06-30",
"功能":"修改-角色资料",
"log": [
	{"date":"06-01" , "dev" :"hzhh" , "content" : ""}
]
}
*/
declare  @role_key int,@role_id varchar(100) , @role_name varchar(100) , @remarks varchar(100)
set @role_key = '{role_key}'
set @role_id = '{role_id}'
set @role_name ='{role_name}' 
set @remarks = '{remarks}'


--校验信息
if isnull(@role_id,'')=''
begin 
	RAISERROR ('SQL:角色id不允许为空', 16 ,1 ) ; 
	return 
end 

--校验信息
if isnull(@role_name,'')=''
begin 
	RAISERROR ('SQL:角色名称不允许为空', 16 ,1 ) ; 
	return 
end 

IF EXISTS(SELECT * FROM y_role WHERE [role_key] <> @role_key and role_id=@role_id)
begin 
	RAISERROR ('SQL:角色id已经存在', 16 ,1 ) ; 
	return 
end 

IF EXISTS(SELECT * FROM y_role WHERE [role_key] <> @role_key and role_name=@role_name)
begin 
	RAISERROR ('SQL:角色名称已经存在', 16 ,1 ) ; 
	return 
end 


update [dbo].[y_role] set
[role_id] = @role_id ,
[role_name] = @role_name ,
[remarks] = @remarks , 
[update_time] = getdate()
where [role_key] = @role_key